import React from 'react';
import ReactDOM from 'react-dom/client';
import 'src/index.css';
import App from './App';
import reportWebVitals from 'src/reportWebVitals';

import { ConfigProvider } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs';

import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import updateLocale from 'dayjs/plugin/updateLocale';
import weekday from "dayjs/plugin/weekday";
import utc from 'dayjs/plugin/utc';

import { isQtClient, mockWebChannelApi } from 'src/ipc/sparkchannel'

dayjs.extend(utc);
dayjs.extend(weekday);
dayjs.extend(updateLocale);

dayjs.updateLocale('zh-cn', {
  weekStart: 1,
});
dayjs.locale('zh-cn');

if (!isQtClient) {
  mockWebChannelApi(import(/* webpackChunkName: 'report_mock' */'./mock'));
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <ConfigProvider locale={zhCN}>
      <StyleProvider hashPriority="high" transformers={[legacyLogicalPropertiesTransformer]}>
        <App />
      </StyleProvider>
    </ConfigProvider >
  </React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
